package com.pension.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.pension.model.dao.BoardDao;
import com.pension.model.dao.MemberDao;
import com.pension.model.dto.Member;

@WebServlet("/board/delete.action")
public class BoardDeleteServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		//1. 요청 데이터 읽기 (글번호)
		String boardNo = req.getParameter("boardno");
		if (boardNo == null || boardNo.length() == 0) {
			resp.sendRedirect("list.action");
			return;
		}
		
		//2. 데이터 처리 (db에서 데이터 변경)
		BoardDao dao = new BoardDao();
		dao.deleteBoard(Integer.parseInt(boardNo));
		
		//3. 목록으로 이동 		
		resp.sendRedirect("list.action");
		
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		doGet(req, resp);
	}
	
}




